added category selector, changed insert code structure