for the .nil? check you can negate by just going ` if idx || idx > 0` etc.