moved logic to main model