Fixing possible null reference exception.