Removing redundant logic