fix subscript out of range