optimize Model.php