Added a null check for getViewer.