Include length in functions and correct typos