updated the query and fixed some code in _home.php and query.php