bugfix with sorting