Fix null-pointer exception