make script more robust against interruption during osmosis