exercise2 for function objects