refactoring a bit more