Converted function into model method