Removing Duplicate code