almost finish all the function of the UI