Adding a function to calculate cluster sizes