Alternate implementation using list and apply for function composition