Split code out to be more manageable