throw error handling added, test added