Simplify code and fix formatting.