cleaned up math in log_det