Completing the new version of the code and adding a GUI