query history function added