fix query history bugs