fixed search and renamed upper vars