Second version

The program works