Fixed segmentation fault in model() method