cleaned up code, changed digits obj to an arr