fixing some null reference errors

thats some deep ternary action there.