figure generation first