search function added with tweaks