Fixed a crash when running the program for the first time