Refactored bit array to be dynamic and set bits from left to right