breaking out most of the functionality into it's own class