refactoring to clean code