fixed bug in publish function
fixed #852