some useful functions and example