fix order of operations error