the version that should work (but does not). Needs debugging