fix bug in clean-up remote script