corrected pivot-related logic in main class, model, and JS class