Replaced expand_dims with keep_dims=True