improve local= function