added sorting and some other cool stuff