I am not sure exactly what you are doing here, but there should be a function in nucname that helps you out.