completed with sorting