Added a useful function and fixed typo