I have adjusted your code slightly in order to have it account for the filleted corners
Posting here in case anyone else needs it too!