add more flexible file locking