A method for counting spatially arranged, moving markers (120 - 127) • wherein said markers (120 - 127) are arranged to move along a movement axis being parallel to a sensors axis of sensors (142 - 146) configured to detect said markers (120 - 127) during movement, whereas there are fewer sensors (142 - 146) than markers (120 - 127), • providing information on a number of markers (120 - 127); • providing information on a sequence of said sensors (142 - 146); • providing information on an initial setup of the system by specifying how many markers (120 - 127) are preceding and following each sensor (142 - 146) taking into account the axis of movement and a direction of an engaging movement; • arranging said sensors, in said initial setup, such that at least two of the sensors (142 - 146) are arranged such that all the markers (120 - 127) precede them taking into account the axis of movement and said direction of the engaging movement; • determining a sensor S T having 0 following markers and a sensor S T-1 following the.S T sensor in the direction of the engaging movement; • awaiting detection of a marker by the sensor S T-1; • determining a sensor S B closest to a starting sensor taking into account said direction of an engaging movement and at the same time having more than 0 detected markers; the method being characterized in that it comprises the steps of: • verifying whether the S B sensor is the starting sensor and in case it is not, determining a number of moved markers (120 - 127) as a sum of detected markers and following markers for the S B; • in the case the verifying step is positive, setting a variable H as a sum of predefined heights of objects associated with said markers (120 - 127) preceding the starting sensor based on the number of markers (110 - 117) preceding the starting sensor as well as the number of markers counted by the starting sensor; • determining a sensor S TT as the closest sensor following S T - H; and • awaiting detection of a marker by the sensor S TT. • wherein said markers (120 - 127) are arranged to move along a movement axis being parallel to a sensors axis of sensors (142 - 146) configured to detect said markers (120 - 127) during movement, whereas there are fewer sensors (142 - 146) than markers (120 - 127), • providing information on a number of markers (120 - 127); • providing information on a sequence of said sensors (142 - 146); • providing information on an initial setup of the system by specifying how many markers (120 - 127) are preceding and following each sensor (142 - 146) taking into account the axis of movement and a direction of an engaging movement; • arranging said sensors, in said initial setup, such that at least two of the sensors (142 - 146) are arranged such that all the markers (120 - 127) precede them taking into account the axis of movement and said direction of the engaging movement; • determining a sensor S T having 0 following markers and a sensor S T-1 following the.S T sensor in the direction of the engaging movement; • awaiting detection of a marker by the sensor S T-1; • determining a sensor S B closest to a starting sensor taking into account said direction of an engaging movement and at the same time having more than 0 detected markers; • verifying whether the S B sensor is the starting sensor and in case it is not, determining a number of moved markers (120 - 127) as a sum of detected markers and following markers for the S B; • in the case the verifying step is positive, setting a variable H as a sum of predefined heights of objects associated with said markers (120 - 127) preceding the starting sensor based on the number of markers (110 - 117) preceding the starting sensor as well as the number of markers counted by the starting sensor; • determining a sensor S TT as the closest sensor following S T - H; and • awaiting detection of a marker by the sensor S TT.