Updated chart function