abstracted logic into separate class