updated to fix the sort error