changed the generate_trac function