Add guard against bad code