refactoring of code