added  error validation on index route while retrieving files