replacing throw error with callback error