fix to properly log errors