Fixing return in error handling