included changes proposed by @ngaranko