I want to understand and try to give a proof of the following claim:
Let $B$ be a compact, connected topological $2$-manifold (surface) with nonempty boundary, then the $S^1$-bundles over $B$ with structure group $O(2)$ are in 1-1 correspondence with $\mathrm{Hom}(\pi_1(B), \mathbb{Z}_2)$.
I am familiar with the basic properties of bundles but not very familiar with how to classify them. It would be extremely helpful if you could help me prove this step by step so I can understand what is the idea here, so I am not completely lost when another similar thing comes up.