add imply and equal, refractored code