moved pPos to local scope, no need for a global variable (QM)