reorganise code layout