added a check for zero length
Merge branch 'master' into hack