removing duplicate LHSs and RHSs