put in functions. Not yet tested.