fixing null reference exception