removes unused imports and fixes loop error