much-needed refactor - part 1