updated and tested snippets