Refactoring, reduced redundant code.