Changed program so that it would function properly