remove extraneous elements