Text this: Tackling impurities in CCS pipelines: An optimization-based approach