code snippets from Ricston blog posts