Fixing bug with "and" and "or"