Fixing minor bug in avatar code