Rewriting handle_key() part4