code cleaning and commenting