handle various input dimensions correctly for b