mostly done, optimizing parameters