ticket:10 saving state to db