add error catching and ability to do further things after successful query