normalizing p to range of x instead of normalizing range of x to p for performance
cleaning code..