fixed a dimension and sign bug