FIX max sortOrder when list is empty
clean up code