It already has functions built in that can be used to do that. Have a look at the code in this screenshot.