Fixed query by non existent reference -> threw an exception uncaught.