Fixed broken logic (oops, I'm tired)