Adding Erik's changes to the second part