fix example
refactor key handling