Updated the search function with "page" option and added some debug prints