List changed by first function gets reset by second function - C#