changed object locking. added count for search