corrected code andadded string function