added comments for functional clarity