finished the view fuction