fix #1712. Number of occurrences was not handled correctly