fixed a minor bug in the key handling