incorporating @memmett's suggestions