Add safeguard for lua error