fix load avatar algorithm