help with JD algoithm (again!)