trying to implement string compaction