Fixed issue with $index not working when zero