bigger refactor in logic