add badcode support