Fixed possible bug.

Bug occurs, if $str is smaller than two, because substr() will have
problems with them.