Function composition: how does it work