re-org the code by idea