fix order-of-operations bug