removed use of length and accessing via list indice