improve avatar function