Changed the w arguments for d (dictionary instead of words)