removed dead code. Improved robustness