Completed basic indexing code