Tidying up search script