Removing redundant lines