rethinkdb query fixes