i am not sure what you mean by reference error how about from line if lock file prefix if lock file prefix endswith lock file name s s lock file prefix  safe name else lock file name s  s lock file prefix  safe name else lock file name safe name