finished main + optional, and commented a little