added lockfile safeguard
added lockfile safeguard