refactor code after code review