Updated with comments and consistent indexing