Added error handling to render