Modified for my specific case. Will update to make more general