Query action

Addresses issue #160 and should finish #183