minor cleanup
improve script running at EOF