Check out this StackOverflow question for a cleaner way to do this sort of thing: http://stackoverflow.com/a/4566550/141395