Refactored composite function and identified a bug in recur.