Ouch, this seems really painful. There's not a better way of doing this?