move query error checking outside processData() function
minor changes