slight modifications for pi