refactored gui rendering code to gui/guirenderer.js