restructure ui code, add history
add controller