working on refactoring code