basic refactoring of code