fix the errors in the critical points calculation