Modified to be compatible with Yii