fix exception handling in render function