Found what I was looking for here:
Explicitly in lines 24-31 and lines 60-68
Hope this helps someone else