some code refactoring for 1st part of task