Fixing null reference