refactor code - tau and M updates