some changes to find an item so there is no race condition