more elegant code generation