adapting the code to the new version of jpc and minor changes