refactor on the way, client main2 code