added error check for swig