Completed fjw -> higher order functions
Refactored to use recursion