added comments for clarity