finished buildcategory function