an almost worked version