First attempt
Accounts for str.length 0