refactored with stuff I learned in week 1