built category factor code; still working out bugs
Fixed all bugs in category factor