optimize code struct and test