improved handling in error template