Refactored redundant code.