Fixed nested expression simplifying logic