trying to fix crash in switching