As proposed in #4 by @alidar, a parse() function was implemented for better overview of what the code does. also added comments