improved generator for toString() method