final version of code for release 2