exercise2 from Tan