Fixed crash when changing views