Added some comments and just cleaned up a little the code