remove unnecessary reinitialization of pop inside loop