Refactored redundant code