I didn't fully understand the original problems. You have already posted an example input, please add also an example output for the same input for the routine you are trying to build. -- Felipe Monteiro de Carvalho