Encode works for the first layer