improvements in difficulty loop