code review & refactor