Simplify and optimize