This seems to be working now. I think it makes this a lot cleaner too.