I created a function to help with this problem. Let me know if you have a better solution.