modified compose function