cleaned up code, clarified varnames, and removed testing lines