Refactored dynamic 0/1 implementation for better readability