fixes #704 added more error checking for joins