sorting is indeed unnecessary
function pointers work