Refactored to use index. Follows lab2a spec given by professor. No leaks.