Fix a bug that will potentially crash the program