needs documenting, but basics are there