fixing the program and cleaning it up