added input modes switch logic