Modifications to p5, still in progress - fix scope issue