Made the code nicer and more efficient.
Merge pull request #7 from blastoy/master

Made the code nicer and more efficient.