plottrace as a seperate function