Final version of pseudo code v1.0