Fix wrong formatting
Improve performance a bit by removing strlen(str) > 0.