move fancy functions to this and rewrite function example