fix view switching bug