Improve code robustness