fix issue with the keys option

next accumulated state was incorrectly given to the function. this
changes fix it.