Code cleanup of search js