code refactoring for better readability