Refactor tk into main