How to remove pattern without losing data