more changes as per comments from @jsha