optimized search, bugfix, code clean