Quick refactoring
Refactored where() to build an AST and always use indexes when possible