Made the code nicer, although not more effective.