added more comments and formatted the code