added some level of encapsulation and prep for unit testing