Added some inline comments for clarification