Refactoring  client side dynamic Pivot