The ideal way to write recursive functions