Added a few comments and reformatted code readability