prepped handle_query for front end
updated index