more correct implementation of operator precedence