Moved to 1-based indexing to avoid indexing problems

See #1 for problem noted