refactoring to make the code clear and simple