Replaced some for loops with extends()