removed bug from sorting