diy period code needs debugging