Ramanujam took notes at the lectures for publication and as he had done previously he showed his deep understanding of mathematics in doing this task

What is the correctly punctuated version of this sentence?
Ramanujam took notes at the lectures for publication and, as he had done previously he showed his deep understanding of mathematics in doing this task.