refactored tgui calls in code