Removing unnecessary elements