added auto publish code