simplified ex. 2 using fmap, and ex. 4