add functions, minor corrections