how to improve performance of code in c#