implemented a bit mask table lookup