In one aspect, the invention relates to a method for finding a best matching string sopt among a set Z of strings for a reference string t, the method comprising: - representing (101), for each pair of strings sz and t, a dynamic programming problem for calculating a final alignment score scz as a matrix Az (300) of cells, each cell Az (i,,j) (316) representing an intermediate result Fz(i,,j)to be calculated; - calculating (102) a current optimal alignment boundary threshold oab- threshold, for each string sz of the set of strings Z, executing: - calculating (104) a prospective final alignment score Pz(i,,j) of a candidate alignment of the strings sz and t for a cell Az(i,,j); - determining (105), if Pz(i,,j) improves the current oab-threshold; - if no improvement is determined, aborting (106) the calculation and prohibiting any extension of the candidate alignment covering said cell Az (i, j); - if an improvement is determined, continuing (107) the calculation for calculating the final alignment score scz for said string sz.