challenge 6 refactored