changed efficiency so single loop is called on search page instead of occasional double loop.