Integrated document template code courtesy of Bri McN