start integrating restresult into select function