Updated chart saving code