added some more robustness