move cost substraction to plotting code