full version (not tested!)