Is this one needed? How can end be accessed without being initialized in this function?