Algorithm updated