Changed the program to work properly