refactoring existing functionality