Format code and simplify some logic