fix sorting and stuff