refactoring, adding print statements, cleaning up