fixed bug with sort