refactoring code