moving stuff from view to model/controller