Refactor gui