clean up the result processing for retrieved queries