@gl3nn or anyone else: Do you know a better way to do this? This looks really ugly but I can't think of anything better.