. . . I want to condense the code for practice with binary . . .
. . . I haven't used binary before . . .
Perhaps you should explain what you mean by 'binary' in this context.
The best I can come up with is that you may possibly be referring to 'Port Manipulation'.
Don