increased robustness; added depth counter