Refactor of layering example