Algorithm optimization (F.Bellini)