fix difficulty algorithm