fixed bugs in sorted layer