added if (swapped==0) to found correct digit case