Fixed bug where app crashes when rotating screen