refactoring code - 1