Single file version working but error handling may need help