structuring code from docs