Refactor compose() to use built-in functions.