fix error null reference exceptions