working branch and bound, fixed performance bottleneck