Better layout for text, but algorithm should be improved