edited so doesn't dismiss viewer if error so user can fix error