Implemented timerange query and orphan query