fix switch bugs