implement better error handling within bilateral