fixed seg fault in sortedCount() method