Move file checking to an erlier point