code changes following review by mjk