implement eric's refactor suggestions