move logic into models, attempt at sorting