changed few method from imperative style to more functional style of programming,removed some print statements