more refactoring to make a more readable codebase