Moved logic into own class