Simplify and add comments