Removed unneeded sort function and fixed naming issues