added direction matrix