added functions and example code