Updated functions of model.php