Optimized the code a little bit.