added last id check