changed string function to include local variable