completed! just need to tidy code and check for any unseen errors with more tests