broke up code into several methods