added the sorting entry to calculations, and corrected the PID