Refactor example code