“There must be an obvious way to do it”.
One of the basic rules. That’s why you must have a look at the SDL