improved formatting by choosing the smallest possible padding length