updated to use proper code, but broke graphing