added missing free() for local string variable