some good refactoring