you have this method also in controller. Maybe you should add this method in model and use where necessary?