fixed some problems with the publish script
fixed some bugs in publish script