Fixed compose algorithm