code for viewing