refactoring controlpanel controllerja