A better way to find string length