Add comments and format the code