consolidated code duplication in import_line function