cleaning and commenting the code