added bucket selection; better variable naming