Removed duplicate and redundant code