functioning code snippets