now basically works, although not tested