final version of code and the write up