refactor a bit and add save operation
support valids save in UI and controller