refactor client script, move the most part to project script