refactored for code quality