maintaning ui state in db