Fix for #258 - not sure on whether I lost changes during a merge or a crash or what - but I've definitely written this code twice