code cleaning and better use of closure classes