Refactor

added functions and a button to improve UX.