refactoring precedence
bugs fixed in rightjoin