First working algorithm #4