cleaning, refactoring and commenting the code