use a bit map instead of binary search