New (more robust and correct) (block) formatting algorithm