First functional version of the program