refactored after code review