Fix null reference exeption