challenge4 updated with functions