moving examples and requiring functions into functions