refactoring for the win