method for calcualte the selection lenght