I don't like this. Would something like this work? http://stackoverflow.com/a/1372096