got the iterative algorithm fixed for conditions, got joins, some sub-queries