move package data extraction into plotting function