Simplify formatting algorithm