refactor maxresult and sort checker