move some model fun from view to model