recognizing algorithm for pupils