Refactored for best practices