Beautified a line of code and added better exception handling for rendering