refactor, fix bug with persist