moved variable setting to publish