modularized some of the operations such as looping through the db object containing all the rows and adding them to a different array