made key handling clearer