Added error handling when rendering views