added more pseudo code / comments for the functions