Clearing a table entry within a loop and retrieving an entity from a table?

I have a table which stores a list of recently changed entities and time for when they should be made free again. the entity also has a variable altered to set its locked state:

table.insert(table,{ent = Entity, Time = CurTime()+5} )
Entity.locked = true

Later on i run a for loop. I want this loop to set the entity’s locked variable to false and then remove the table entry for it so when the loop runs again the entity is not affected.:

		for k,v in pairs(table) do
			if ( CurTime() >= Time ) then
				v.ent.locked = false
				table[k] = nil

currently the entity remains locked and i get pages of “table index is nil”.

I assume here that what im actually doing is setting the ent locked variable within the table rather than the entity itself.

As for removing the table entry ive tried table.remove.

How do i do this?

do: table[k] = nil !

still get table index is nil erros