refactor following code review