trimmed down the example code