Refactored after code review feedback