PORTB problem

A useful technique when you go off the Arduino piste (where function names and meaningful variable names aid the narrative) is to comment your code.
Then, we can see your intent, and see if the code matches your expectations.