Rewrote search functions