free unreferenced problem fixed