Your lookup function appears to destroy your list. It certainly shouldn't do any copying, just comparing.