bad key bug fix