Working copy

previous version didn't work for some reason. Here's an earlier version
that does work