working. Cleaning up code and looking at ways to refactor