More efficient bin calculation