improved templates error code