Move file probing logic into separate function for better readablity