Fixed a bug that terminated the app