Check for string before replacing. Fixes #6