fixing exception being thrown with stopping program