improve code robustness