Mostly working example solution