Move createChainedFunction into utils/