updated to work with new return type of tablegateway