Wrote the two functions requested.