Refactor code after code review