This is sooo ugly. But I assume you don't have any other choice.