Wrote length functions.