remove unnecessary elements