fixed bug in sorted results