mostly done, code needs to be cleaned