refactored the showChart script