add comments, update sql handling