Tutorial code restructure