Refactor the import functionality