cleaned up the code in categorypanelcontroller