checking to make sure value is string before attempting a replace