fix minor bug in key handling