corrected salt function