fixed bug where program wouldn't finish