change ipairs to pairs