first attempt to shorten code2