Added code snippets for questions