Adding code for the second assignement.