How to handle null reference exception in c# | object reference not set to an instance of an object