Fix null reference crash