Pseudo Coded based on slides