Fixing issue where some errors was not caught