Refactored after code review with Joe