improvements following review by timgraham