implemented the whole thing.