refactor bbox code, part 2 of 2