added file checking