Another question? What is setting this: omranding variable. If it's empty or nil, can the command still work? Also, is there any reason that the layer z-arc wouldn't exist? Just a thought here, but if it didn't exist, turning it one would merely crash your routine from the start. Just to be clear, you might consider using (layer make z-arc), then turning it on and making sure it's thawed and unlocked. Using make will either create it if it doesn't exist and set it as the current layer, or just set it as the current layer if it does already exist. If you don't wish to have it set as the current layer, you should still employ the above to make sure all possible issues are resolved, then set the desired layer. As for the real problem, do you want to test for refname NOT nil, meaning you're in a refedit command, or (refname nil)? Also, and maybe this is me getting here late, but why are you using while here?