added second, presumably faster, method of doing this