add functions and tests