basically working, lots of refactors a head