Amended search function so works by updating variable name