You can't compare the two maps with !=, because it compares the string representation of the maps, so it will work only randomly.