time util and query bug fix