Replace [] slicing with taking a reference.