refactored for best practices