implement changes from comments by aochagavia