refactored gui.js