add `local` option

and code improvement