closing statement and using callbacks to perform operation on result set