refactor according to code review