difficulty function first version