Fixed critical bug that caused app to crash