add lock to check_file