Corrected version (end-game step fixed)