Separated code in Model into more functions