restructure, with logic this time