Avoiding pop error in dict