corrections after code review by @blkperl