refactoring an funcationalising