improvements suggested by @bigzaphod