all funcs tested, but need to tidy up a bit