few changes based on comments from @jrrideout