added improvements for robustness