I have written this version before changing the program to look like Gustavo's code