Compose function implementation