add file checking function