refactoring, making code more generic