fixed bug resetting the history every generation