working version of pypredvar