Got the script to return correct altered string. Moving on to exception handling.