added throw error flag