changed function call to be independant of (D, p)