Fixes mode toggling issue