solving section2 pure functional