fix time query bugs