working out the view function