add second half of challenge 1 and refactor