refactoring based on file lock