a version of the last one that works