fix bugs with viewing flag