[encode] refactor encode element