revamped key handling