Cleanup and better sorting
new version