Added pseudo code