Challenge 9 functional - need to consolidate repeated code.