Added some comments
Moved all the parsing into its own function