added a check for valid view object