is there is a way to make this faster - C#