fix logic for error handling, use helper.handleError for convient.