added handling of keys