Fix nullpoint exception