fix query end