refactored the pack updateChart function