Function to compose functions