Removing redundant if block