adjust logic per ian's suggestions