almost done, code needs cleanup