UI code refactoring
bug fixes for the previous ui refactoring