workaround code for badgap error