Refactored GUI and added an encoding method