refactoring average_face for export