I wonder if there is a more elegant way to do this..