Moved template rendering code outside the try block, #16