extract logic into class