separated out chart code