simlify logic