refactoring to improve readability of code