fixing empty Mat case