Added some comments and fixed indentation