reorganized stuff and moved query object into separate module