started pivot function, dealing with some issues now