extracting code from Design guide - needs more work