improve file checking