Correctly use 0-based indexing