These are homework2 codes