initial porting from quals version