updated key handling