handles error on mode changing