equal function for each type