Move class-name generation into separate function