fixed ensureCap bug