everything working

crash at the very end of the program might have been solved, but unsure
as it only happens sometimes