modifying code for refactoring