added error message for bad querry
updated last result hanler
updated syntax error
updated syntax error
updated syntax error
updated output formating