slightly updated code snippets