compose a couple of functions and fix reference errors