implementation of the UI and JS logic