refactor model and persistent

passing built in tests