Rewriting handle_key() part 3