Condensed the code a little.