Fixed scoping issue in name setting