Ammended condition around incrementing depth of string. Added code documentation.