refactored control rendering code to gui/guicontrol.js