The effects of oxygen and nitrogen adsorption on secondary ion energy spectra