Fixed bug that caused crash when orientation changed