fix formatting and add comments