Fixed a bug that caused a crash