fix key handling