added a cap function by popular demand