Fisrt version of pseudo code