fixed search and code cleanup