cleaned bob's refactor