try to move logic into main page