Simplified the code a little.