refactor file locking