Added some comments. Made it more readable.