modifications to make clustering a bit more efficient hopefully