add logic to update temporal matrix