Fixed search query and added debugging code