Added comments and made code look beautiful