added commets to all functions