Improve persistance algorithm