fix the shitty-ass hopeless sorting and heading code for the last goddamn time