added mapping over X and error. note: inefficient for now