changing the doit method to completely evaluate functions and some type checking.